/***********************************************************************
 * Module:  Drzava.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class Drzava
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class Drzava implements Serializable {

	protected Integer id;
	protected String sifraDrzave;
	protected String nazivDrzave;
	protected int verzija;

	protected Collection<Mesto> mesta;

	public Collection<Mesto> getMesta() {
		if (mesta == null)
			mesta = new HashSet<Mesto>();
		
		return mesta;
	}

	public Iterator<Mesto> getIteratorMesta() {
		if (mesta == null)
			mesta = new HashSet<Mesto>();
		
		return mesta.iterator();
	}

	public void setMesta(Collection<Mesto> newMesta) {
		removeAllMesta();
		for (Iterator<Mesto> iter = newMesta.iterator(); iter.hasNext();)
			addMesto((Mesto) iter.next());
	}

	public void addMesto(Mesto newMesto) {
		if (newMesto == null)
			return;
		if (this.mesta == null)
			this.mesta = new HashSet<Mesto>();
		if (!this.mesta.contains(newMesto))
			this.mesta.add(newMesto);
	}

	public void removeMesto(Mesto oldMesto) {
		if (oldMesto == null)
			return;
		if (this.mesta != null)
			if (this.mesta.contains(oldMesto))
				this.mesta.remove(oldMesto);
	}

	public void removeAllMesta() {
		if (mesta != null)
			mesta.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSifraDrzave() {
		return sifraDrzave;
	}

	public void setSifraDrzave(String sifraDrzave) {
		this.sifraDrzave = sifraDrzave;
	}

	public String getNazivDrzave() {
		return nazivDrzave;
	}

	public void setNazivDrzave(String nazivDrzave) {
		this.nazivDrzave = nazivDrzave;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}